# -*- coding: utf-8 -*-
from django.db import models
from django.core.validators import MaxLengthValidator
from django.contrib.auth.models import User
from hackprofile import settings

PROGRAMMING_LANGS = getattr(settings, 'PROGRAMMING_LANGS', (
    ('C', 'C'),
    ('C++', 'C++'),
    ('JVM', 'JVM (Java/Closure/Groovy/SCALA/Jython'),
    ('Erl', 'Erlang'),
    ('.NET', '.NET (C#/Managed C++)'),
    ('Perl', 'Perl'),
    ('Python', 'Python'),
    ('PHP', 'PHP'),
    ('Deadthy', 'Delphi'),
))

OPERATING_SYSTEMS = getattr(settings, 'OPERATING_SYSTEMS', (
    ('FailOS', 'Microsoft (C) Windows (R)'),
    ('debian', 'Debian/Ubuntu/*buntu'),
    ('gentoo', 'Arch/Gentoo'),
    ('rh', 'Red Hat/Fedora/CentOS'),
    ('mac', 'Mac OS'),
    ('linux', u'Другой Linux')    
))


class Hacker(models.Model):
    user = models.ForeignKey(User, unique=True)
    icq = models.IntegerField(null=True, blank=True)
    jabber = models.CharField(max_length=255, blank=True, null=True)
    about = models.TextField(validators=[MaxLengthValidator(512)],
                null=True, blank=True)
    interests = models.TextField(validators=[MaxLengthValidator(256)],
                null=True, blank=True)
    avatar = models.ImageField(upload_to=settings.AVATARS_PATH, null=True,
                blank=True)
    site = models.URLField(null=True, blank=True)
    twitter = models.CharField(max_length=50, blank=True, null=True)
    skype = models.CharField(max_length=50, blank=True, null=True)
    OS = models.CharField(max_length=20, choices=OPERATING_SYSTEMS,
                null=True, blank=True)
    favproglang = models.CharField(max_length=20, choices=PROGRAMMING_LANGS,
                null=True, blank=True)
    
    class Meta:
        permissions = ( ('can_moderate_profile', 'Can moderate profile'), )
    
    @models.permalink    
    def get_absolute_url(self):
        return ('show-profile', (), {
            'pk': self.pk, })

    def __unicode__(self):
        return u"Hacker profile for %s" % self.user
    


    
class ForumProfile(models.Model):
    user = models.ForeignKey(User, unique=True)
    caption = models.TextField(null=True, blank=True)
    posts_count = models.IntegerField(null=True, editable=False)
    
    class Meta:
        permissions = ( ('can_moderate_profile', 'Can moderate profile'), )
    
    @models.permalink
    def get_absolute_url(self):
        return ('show-profile', (), {
         'pk': self.pk, })
        
    def __unicode__(self):
        return u"Forum profile for %s" % self.user
